package com.neuedu.javase;

/**
 * @auth 金山老师
 * title:   书籍代码
 * creatime: 2022-09-22 8:45
 * 描述 : 逻辑运算
 */
public class Operator4 {

    /**
     * 逻辑运算
     * @param args
     */
    public static void main(String[] args) {

        int age = 60;
        char gender = '男';


        //男性  退休的条件 成不成立

        boolean success = age>=60   &&   gender == '男';

        System.out.println("age = " + age);
        System.out.println("gender = " + gender);
        System.out.println("退休的条件是否成立: "+success);
        System.out.println();



        gender = '女';
        success = age>=60   &&   gender == '男'   ;

        System.out.println("age = " + age);
        System.out.println("gender = " + gender);
        System.out.println("退休的条件是否成立: "+success);
        System.out.println();




        //男性 60上  或者  女性 55以上


        success  =  (age>=60   &&   gender == '男' ) ||  (age>=55   &&   gender == '女');

        System.out.println("age = " + age);
        System.out.println("gender = " + gender);
        System.out.println("退休的条件是否成立: "+success);
        System.out.println();

        // 短路
        gender = '男';
        age = 61;

        success  =  (age>=60   &&   gender == '男' ) ||  (age++>=55   &&   gender == '女');

        System.out.println("age = " + age);
        System.out.println("gender = " + gender);
        System.out.println("退休的条件是否成立: "+success);
        System.out.println();

        System.out.println("true && true = " + (true && true));   // true
        System.out.println("false && false = " + (false && false)); //fasle
        System.out.println("true && false = " + (true && false)); //fasle
        System.out.println("false && true = " + (false && true));//false
        System.out.println(); // 输出带换行

        System.out.println("false || false = " + (false || false)); //fasle
        System.out.println("true || true = " + (true || true));   // true
        System.out.println("true || false = " + (true || false)); //true
        System.out.println("false || true = " + (false || true));//true



    }


}
